package online.abor;

/**
 * 题目：输入两个正整数m和n，求其最大公约数和最小公倍数。
 * 程序分析：利用辗除法。
 */
public class Topic06_DivisionAlgorithm {
    public static int getGreatestCommonDivisor(int number1,int number2){
        int largeNumber = Math.max(number1, number2);
        int smallNumber = Math.min(number1, number2);
        int modNumber = largeNumber%smallNumber;
        while (modNumber!=0){
            largeNumber = smallNumber;
            smallNumber = modNumber;
            modNumber = largeNumber%modNumber;
        }
        return smallNumber;
    }
    public static int getLowestCommonMultiple(int number1,int number2){
        return number1*number2/getGreatestCommonDivisor(number1,number2);
    }
}
